Stored Procedures [dbo].[asi_CreateGLExportItems]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@glExportKeyuniqueidentifier16
SQL Script
CREATE  PROCEDURE [dbo].[asi_CreateGLExportItems]
@glExportKey uniqueidentifier
AS
DECLARE
    @FinancialEntityKey uniqueidentifier,
    @BeginDate datetime,
    @EndDate datetime

--Get the filter variables from the GLExport record
SELECT @BeginDate = BeginDate, @EndDate = EndDate, @FinancialEntityKey = FinancialEntityKey FROM GLExport WHERE GLExportKey = @glExportKey
    
--Delete existing GLExportItems incase this is an update
DELETE GLExportItem Where GLExportKey = @glExportKey

BEGIN
    INSERT INTO GLExportItem(GLExportKey, GLTransactionKey)
    SELECT @glExportKey AS GLExportKey, GLTransactionKey
    FROM GLTransactionMain
    WHERE FinancialEntityKey = @FinancialEntityKey AND DATEDIFF(Day,TransactionDate, @EndDate) >= 0 AND DATEDIFF(Day,TransactionDate, @BeginDate) <= 0 AND GLTransactionKey NOT IN (SELECT GLTransactionKey FROM GLExportItem) ORDER BY TransactionDate
END

GO
Uses